#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
using ll = long long;
using T = int;
T rad(); // quick read
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
const int max_size = 5 + 100;
const int maxn = 5 + 5e6;

int a[maxn], mul[maxn] = {1, 1};
int inv[maxn], inv_mul[maxn];

/*
mul[i] = pi(a[1], a[i])
inv_mul[i] = inv_mul[i + 1] * a[i + 1] % mod;
inv[i] = inv_mul[i] * mul[i - 1] % mod;
*/

int exgcd(int a, int b, int &x, int &y) {
    if (b == 0) return x = 1, y = 0, a;
    int ret = exgcd(b, a % b, y, x);
    y -= a / b * x;
    return ret;
}

int get_inv(int i, int mod) {
    int x, y, g = exgcd(i, mod, x, y);
    return g == 1 ? (x + mod) % mod : -1;
}

int main() {
    int n = rad(), mod = rad();
    ll k = rad();
    rf(i, n) {
        a[i] = rad();
        mul[i] = (ll)mul[i - 1] * a[i] % mod;
    }

    inv_mul[n] = get_inv(mul[n], mod);
    for (int i = n - 1; i > 0; --i) {
        inv_mul[i] = (ll)inv_mul[i + 1] * a[i + 1] % mod;
    }
    rf(i, n) inv[i] = (ll)mul[i - 1] * inv_mul[i] % mod;

    ll tmp = k, ans = 0;
    rf(i, n) {
        ans = (ans + tmp * inv[i] % mod) % mod;
        tmp *= k, tmp %= mod;
    }
    printf("%lld", ans);
}

T rad() {
    T back = 0;
    int ch = 0, posi = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        posi = ch ^ '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return posi ? back : -back;
}
